package koction.model.reviewBoard;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class ReviewBoardDaoImpl implements ReviewBoardDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public int writeReviewBoard(ReviewBoardVO rvo) {
		return sqlSessionTemplate.insert("reviewBoard.writeReviewBoard",rvo);
	}

	@Override
	public ReviewBoardVO showContentReviewBoard(int reviewNo) {
		return sqlSessionTemplate.selectOne("reviewBoard.showContentReviewBoard",reviewNo);
	}
	
	@Override
	public int deleteReviewBoard(int no) {
		return sqlSessionTemplate.delete("reviewBoard.deleteReviewBoard",no);
	}

	@Override
	public int updateReviewBoard(ReviewBoardVO rvo) {
		return sqlSessionTemplate.update("reviewBoard.updateReviewBoard",rvo);
	}

	@Override
	public ArrayList<ReviewBoardVO> getReviewBoardList(String productId) {
		return (ArrayList)sqlSessionTemplate.selectList("reviewBoard.getReviewBoardList",productId);
	}

	@Override
	public int updateCountReviewBoard(int reviewNo) {
		return sqlSessionTemplate.update("reviewBoard.updateCountReviewBoard",reviewNo);
	}

	@Override
	public int totalContentReviewBoardByproductId(String productId) {
		return sqlSessionTemplate.selectOne("reviewBoard.totalContentReviewBoardByproductId",productId);
	}

	@Override
	public List<ReviewBoardVO> getReviewBoardListPaging(Map map) {
		return (List)sqlSessionTemplate.selectList("reviewBoard.getReviewBoardListPaging",map);
	}


}
